/**
 * 
 */
package com.doone.telmarket.vo;

import java.io.Serializable;

import com.doone.telmarket.domain.VerifyState;

/**
 * @author 吴同庆
 * @date 2009-10-13
 * @description 评论查看值对象
 * @package com.doone.telmarket.vo
 */
public class CommentView implements Serializable {

	private static final long serialVersionUID = 2898580861398269415L;

	public static final String PAGE_NUM_ERROR = "传入的页码小于1，请检查";

	private final static int INIT_COUNT = 1;

	private final static int MAX_COUNT = 10;

	private Integer serviceCode;

	private VerifyState verifyState;

	private int minRowNum;

	private int maxRowNum;

	public CommentView(Integer serviceCode, String verifyState, int pageCount) {
		initRownum(pageCount);
		this.serviceCode = serviceCode;
		this.verifyState = VerifyState.valueOf(verifyState);
	}

	public CommentView(Integer serviceCode, int pageCount) {
		initRownum(pageCount);
		this.serviceCode = serviceCode;
		verifyState = VerifyState.VPS;
	}

	private int computerMinRowNum(int pageCount) {
		return (pageCount - INIT_COUNT) * MAX_COUNT + INIT_COUNT;
	}

	private int computeMaxRowNum(int pageCount) {
		return pageCount * MAX_COUNT + INIT_COUNT;
	}

	private void initRownum(int pageCount) {
		if (pageCount < INIT_COUNT)
			throw new RuntimeException(PAGE_NUM_ERROR);
		minRowNum = computerMinRowNum(pageCount);
		maxRowNum = computeMaxRowNum(pageCount);
	}

	public Integer getServiceCode() {
		return serviceCode;
	}

	public VerifyState getVerifyState() {
		return verifyState;
	}

	public int getMinRowNum() {
		return minRowNum;
	}

	public int getMaxRowNum() {
		return maxRowNum;
	}

}
